package com.baosight.sczx.zm.cl.service;

import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.basetools.StaticTools;
import com.baosight.sczx.common.zm.cInterface.Department;
import com.baosight.sczx.common.zm.cInterface.cs.InitialData;
import com.baosight.sczx.zm.cf.domain.ZMCFPenalty;

/**
 * 罚款记录
 * 针对隐患\三违罚款记录
 * <p>Title: ServiceZMCL75.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 严洪浩
 * @version 1.0
 * <pre>Histroy:
 *          2011-10-12 上午09:30:39  严洪浩  Create
 *</pre>
 */
public class ServiceZMCL75 extends ServiceEPBase {

	/**
	 * 初始进入
	 * <p>Function: initLoad</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCL70</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-8-5上午07:50:22 严洪浩
	 * </p>
	 *
	 */
	@Override
	public EiInfo initLoad(EiInfo inInfo) {
		inInfo.addBlock(EiConstant.resultBlock).set("showCount", "true");//如果不加这个，翻页的统计和显示是错误的
		EiInfo outInfo  = this.query(inInfo);
		
		outInfo.addBlock(InitialData.getInstance().getEiBlockByNo("cmes.cl.penaltyType", "cmes.cl.penaltyTypes", true));
		outInfo.addBlock(Department.getInstance().getConstructionUnit(false));
		
		return outInfo;
	}
	
	/**
	 * 查询
	 * <p>Function: query</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCL70</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-8-5上午07:51:16 严洪浩
	 * </p>
	 *
	 */
	@Override
	public EiInfo query(EiInfo inInfo) {
		String fdPenaltyIds = inInfo.getString("fdPenaltyIds") == null ? "" : inInfo.getString("fdPenaltyIds");
		
		String _temp[] = fdPenaltyIds.split(",");
		StringBuffer fdKeyIds = new StringBuffer();

		for(int i = 0; i < _temp.length; i++){
			if(i==0) {
				fdKeyIds.append("'"+_temp[i]+"'");
			}
			else {
				fdKeyIds.append(",'"+_temp[i]+"'");
			}
		}
		
		StaticTools.setQueryParameters(inInfo, "fdKeyIds", fdKeyIds, true);//添加查询条件
		StaticTools.setQueryParameters(inInfo, "fdStatus", "生效", true);//添加查询条件
		inInfo.addBlock(EiConstant.resultBlock).set(EiConstant.offsetStr, 0);
		inInfo.getBlock(EiConstant.resultBlock).set(EiConstant.limitStr, 100);
		inInfo.getBlock(EiConstant.resultBlock).set(EiConstant.isCountFlag, true);
		EiInfo outInfo = super.query(inInfo, "ZMCFPenalty.query", new ZMCFPenalty());
		
		return outInfo;
	}
}
